<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //如果是代理的set和map，就要注意其方法的this指向，如果不改变this的指向，就无法操作其方法
        let s = new Set()
        let proxy = new Proxy(s, {
            get(target, key) {
                //判断如果是方法，就要修正this指向
                let value = target[key]
                if (value instanceof Function) {
                    return value.bind(target) //将this指向target，target也就是s
                }
                return value
            },
            set() {
                console.log("set")
            }
        })
    </script>
</body>

</html>